/* -*-c++-*- */
/* osgGIS - GIS Library for OpenSceneGraph
 * Copyright 2007-2008 Glenn Waldron and Pelican Ventures, Inc.
 * http://osggis.org
 *
 * osgGIS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */

#ifndef _OSGGIS_PAGED_LAYER_COMPILER2_H_
#define _OSGGIS_PAGED_LAYER_COMPILER2_H_ 1

#include <osgGIS/Common>
#include <osgGIS/FeatureLayer>
#include <osgGIS/FilterGraph>
#include <osgGIS/LayerCompiler>
#include <osg/Node>
#include <string>

namespace osgGIS
{
    /* (probably to be deprecated)
     * Compiles a feature layer against a terrain.
     */
    class OSGGIS_EXPORT PagedLayerCompiler : public LayerCompiler
    {
    public:
        /**
         * Constructs a new paged layer compiler.
         */
        PagedLayerCompiler();
            
        /**
         * Sets the priority offset of the resulting model's PagedLOD
         * tiles, so as to force them to load before or after their
         * corresponding terrain tiles.
         */
        void setPriorityOffset( float po );

        /**
         * Compiles a feature layer against a reference terrain and
         * returns the root node.
         *
         * @param layer
         *      Feature layer to compile
         * @param output_file
         *      File to which to write root level output node. All other subtile
         *      nodes will be written to the same directory.
         */
        std::string compile(
            FeatureLayer*      layer, 
            const std::string& output_file );

    private:
        float                          priority_offset;
        
        bool        is_geocentric;
        std::string output_dir;
        std::string output_prefix;
        std::string output_extension;
        double      layer_min_range;
        double      layer_max_range;
        
        std::string compileAll(
            FeatureLayer*    layer,
            const GeoExtent& extent );
            
        void compileTile(
            FeatureLayer*      layer,
            int                level,
            osg::Node*         tile_terrain,
            const GeoExtent&   tile_extent,
            double             tile_max_range,
            const std::string& tile_filename );
            
            
        osg::Node* compileGeometry(
            FeatureLayer*    layer,
            int              level,
            osg::Node*       tile_terrain,
            const GeoExtent& tile_extent,
            double           tile_min_range,
            double           tile_max_range );
    };
}


#endif //_OSGGIS_PAGED_LAYER_COMPILER2_H_
